package com.dwy2002.room;

import com.dwy2002.common.Result;
import com.dwy2002.common.annotation.RequiresPermission;
import com.dwy2002.enums.Logical;
import com.dwy2002.pojo.vo.UploadImagesVO;
import com.dwy2002.room.service.IRoomImagesService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2025/05/07
 */
@RestController
@RequestMapping("/rooms/image")
@RequiredArgsConstructor
public class RoomImagesController {
    private final IRoomImagesService service;

    /**
     * 用于删除课程图片
     *
     * @param id 课程图片id
     * @author 杜伟毅
     * @since 2025/5/7 0007 13:29
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @DeleteMapping("/{id}")
    public Result<Void> deleteImage(@PathVariable String id) {
        return service.deleteImage(id);
    }

    /**
     * 用于上传包间图片
     *
     * @param images 图片文件
     * @author 杜伟毅
     * @since 2025/1/26 0026 16:53
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @PostMapping
    public Result<List<UploadImagesVO>> uploadRoomsImages(@RequestParam("images") List<MultipartFile> images) throws IOException {
        return service.uploadRoomsImages(images);
    }
}
